package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试
 */
@RestController
@RequestMapping("/admin/product/test")
public class TestController {

    @Autowired
    private TestService testService;

    //请求
    @GetMapping("testLock")
    public Result testLock(){
        testService.testLock();

        return Result.ok();
    }
    //上读锁  读
    @GetMapping("/read")
    public Result readLock(){
        Object readLock = testService.readLock();
        return Result.ok(readLock);
    }
    //上写锁  写
    @GetMapping("/write")
    public Result writeLock(){
        testService.writeLock();
        return Result.ok();
    }
}
